<template>
  <a-table :columns="columns" :data-source="records" rowKey="id" bordered>
    <span slot="fileName" slot-scope="text, record">
      {{ record.bidFile.fileName + '.' + record.bidFile.fileType }}
    </span>
  </a-table>
</template>

<script>
import { getAction, postAction } from '@/api/manage'
export default {
  props: {
    contractId: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      columns: [
        {
          title: '所属附件名称',
          dataIndex: 'formName',
          key: 'formName',
        },
        {
          title: '文件名称',
          scopedSlots: { customRender: 'fileName' },
        },
        {
          title: '上传人',
          dataIndex: 'modifyUser',
          key: 'modifyUser',
        },
        ,
        {
          title: '上传时间',
          dataIndex: 'modifyTime',
          key: 'modifyTime',
        },
      ],
      records: [],
      urls: {
        loadContractAttach: '/hte/contract/loadContractAttach',
      },
    }
  },
  mounted() {
    this.fetchList()
  },
  methods: {
    fetchList() {
      getAction(this.urls.loadContractAttach + '/' + this.contractId, {}).then((res) => {
        if (res.success) {
          this.records = res.result
        }
      })
    },
  },
  watch: {
    contractId(newV, oldV) {
      if (newV > 0) {
        this.fetchList()
      } else {
        this.records = []
      }
    },
  },
}
</script>

<style>
</style>